package com.qdxwx.manage.interceptor;

import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SessionListener implements HttpSessionListener {

    public static final Logger logger = LoggerFactory.getLogger(SessionListener.class);


    /*
    此方法是HttpSessionAttributeListener
    @Override
    public void attributeAdded(HttpSessionBindingEvent httpSessionBindingEvent) {
        HttpSession session = httpSessionBindingEvent.getSession();
        logger.info("--attributeAdded：{}--", session.getId());
        logger.info("key----:" + httpSessionBindingEvent.getName());
        logger.info("value---:" + httpSessionBindingEvent.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent httpSessionBindingEvent) {
        logger.info("--attributeRemoved--");
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent httpSessionBindingEvent) {
        logger.info("--attributeReplaced--");
    }
   */

    @Override
    public void sessionCreated(HttpSessionEvent event) {

        //HttpSession session = event.getSession();
        //logger.info("---sessionCreated：{}----", session.getId());
        //这里可以进行操作

        //添加新建的session到MySessionContext中;
        //MySessionContext.AddSession(event.getSession());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent event) throws ClassCastException {
        //HttpSession session = event.getSession();
        //logger.info("---sessionDestroyed：{}----", session.getId());
        //添加新建的session到MySessionContext中;
        //MySessionContext.DelSession(session);
    }
}
